/////////////////////////////////////////////     File     //////////////////////////////////////////////////
// Author: James Chen
// Filename: CBallisticCalculator.h
// Created: Sunday, October 17, 2010 9:21:51 AM
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "CUtilities.h"

enum DRAGTYPE{G1 = 1, G2, G5, G6, G7, G8};


struct DragModelData
{
	double ProjectileVelocity;
	double A;
	double M;

	DragModelData(double vp = -1, double a = -1, double m = -1)
	{
		this->ProjectileVelocity = vp;
		this->A = a;
		this->M = m;
	}
};


/////////////////////////////////////////////     Class     /////////////////////////////////////////////////
// Name: CBallisticCalculator
// Author: James Chen
// Created: Sunday, October 17, 2010 9:21:52 AM
//
// Purpose: Handles the drag functions for 3 DOF ballistic calculations
//
// Revisions: 
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
class CBallisticCalculator
{
	////////////////////// Singleton Implementation Begins //////////////////////
private:

	CBallisticCalculator(void);
	CBallisticCalculator(const CBallisticCalculator&);
	CBallisticCalculator& operator =(const CBallisticCalculator&);
	static CBallisticCalculator *m_pInstance;

public:

	virtual ~CBallisticCalculator(void);
	static CBallisticCalculator *GetInstance(void);
	static void DeleteInstance(void);
	/////////////////////// Singleton Implementation Ends ///////////////////////

	//Retardation
	
private:

	vector<DragModelData> G1Model;
	vector<DragModelData> G2Model;
	vector<DragModelData> G5Model;
	vector<DragModelData> G6Model;
	vector<DragModelData> G7Model;
	vector<DragModelData> G8Model;

	DragModelData RetardValue;

	double A;
	double M;

	double LastValue;

	double LastVelocity;
	double LastDragCoefficient;
	DRAGTYPE LastDragType;
	
	double Progression;

public:

	void PopulateDragModels(void);

	double RetardationEstimation(DRAGTYPE drag, double DragCoefficient, double Velocity);

	DragModelData Retard(DRAGTYPE drag, double DragCoefficient, double Velocity);

};